home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / utility / gs25dos1.zip / FONTS.DOC < prev    next >
Text File  |  1992-08-10  |  12KB  |  263 lines

  1.    Copyright (C) 1990, 1991 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.
  19.  
  20. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  21.  
  22. This file, fonts.doc, describes the fonts and font facilities supplied
  23. with Ghostscript.
  24.  
  25. For an overview of Ghostscript and a list of the documentation files, see
  26. README.
  27.  
  28. About Ghostscript fonts
  29. =======================
  30.  
  31. The fonts included with Ghostscript come in several parts:
  32.  
  33.     - Font data in files *.gsf and *.pfa: each file defines one
  34.       (transformable) font specified in outline form.
  35.  
  36.     - BuildChar procedures in gs_fonts.ps: these provide the
  37.       algorithms for interpreting the data in the .gsf or .pfa files.
  38.  
  39.     - The Fontmap file: this relates Ghostscript font names to .gsf
  40.       or .pfa file names. 
  41.  
  42. Currently, most of the fonts supplied with Ghostscript are based on
  43. various public domain bitmap fonts, primarily the ones supplied with the
  44. X11 distribution from MIT, and on the public domain Hershey fonts.  The
  45. fonts are distributed in the file `ghostscript-N.NNfonts.tar.Z'.  The
  46. bitmap-derived fonts include the usual Helvetica, Times-Roman, and so on;
  47. see the file `Fontmap' for the complete list, in the usual roman, italic,
  48. bold, and bold italic styles (for the most part).  The Hershey fonts, on
  49. the other hand, are quite different from traditional ones; the file
  50. `hershey.doc' describes them in more detail.
  51.  
  52. There is also a single rather heavy home-grown font called Ugly.  This
  53. font is the file `uglyr.gsf' in the Ghostscript source distribution.
  54.  
  55. The file gs_fonts.ps, which is loaded as part of Ghostscript
  56. initialization, arranges to load fonts on demand using the information
  57. from Fontmap.  If you want to preload all of the known fonts, invoke the
  58. procedure
  59.     loadallfonts
  60. This is not done by default, since the fonts occupy about 50K each and there
  61. are a lot of them.
  62.  
  63. Ghostscript fonts are actually ordinary Ghostscript programs: they use the
  64. extension .gsf instead of .ps simply to be informative.  This convention
  65. is only embodied in the Fontmap file: there is no code that knows about
  66. it.
  67.  
  68. If you want to try out the fonts, prfont.ps contains code for printing a
  69. sampler.  Load this program, by including it in the gs command line or by
  70. invoking
  71.     (prfont.ps) run
  72. and then to produce a sampler of a particular font, invoke
  73.     /fontName DoFont
  74. e.g.
  75.     /Times-Roman DoFont
  76.  
  77. Contents of fonts
  78. -----------------
  79.  
  80. A Ghostscript font is a dictionary with a standard set of keys as follows.
  81. The keys marked with a * have the same meanings as in P*stScr*pt fonts;
  82. those marked with # have the same meanings as in Adobe Type 1 fonts.  Note
  83. that FontName is required; StrokeWidth is required for all stroked or
  84. outlined fonts; and Metrics is not currently supported.
  85.  
  86. *    - FontMatrix <array>: the transformation from character
  87.       coordinates to user coordinates.
  88.  
  89. *    - FontType <integer>: the type of the font, either 1 or 3.
  90.  
  91. *    - FontBBox <array>: the bounding box of the font.
  92.  
  93. *    - Encoding <array>: the map from character codes to character
  94.       names.
  95.  
  96. *    - FontName <name>: the name of the font.
  97.  
  98. *    - PaintType <integer>: an indication of how to interpret the
  99.       character description from CharInfo.
  100.  
  101. *    - StrokeWidth <number>: the stroke width for outline fonts.
  102.  
  103. *    - FontInfo <dictionary>: additional information about the font
  104.       (optional, not used by the standard Ghostscript software).
  105.  
  106. *    - UniqueID <integer>: a unique number identifying the font.
  107.  
  108. *    - BuildChar <procedure>: the procedure for showing a character
  109.       (not required in type 1 fonts).
  110.  
  111. #    - CharStrings <dictionary>: the map from character names to character
  112.       descriptions (relevant only in type 1 fonts).
  113.  
  114. #    - Private <dictionary>: additional information used by the
  115.       algorithms for rendering outlines fonts (relevant only in type 1
  116.       fonts).
  117.  
  118. The format of values in the CharStrings and Private dictionaries are
  119. described in the Adobe Type 1 Font Format book.
  120.  
  121. Adding your own fonts
  122. =====================
  123.  
  124. The program bdftops.ps (and invoking shell script bdftops.bat or bdftops)
  125. converts these bitmap files to Ghostscript input, using the Ghostscript
  126. ``type1imagepath'' operator to convert the bitmaps into outlines.
  127.  
  128. If you want to add fonts of your own, you need to do two things.  First,
  129. edit Fontmap to include an entry for your new font at the end.  The format
  130. for entries is documented in the Fontmap file.  Second, you need to
  131. prepare the .gsf file.  If you are converting a file from BDF format, the
  132. Ghostscript distribution already includes a program for doing this: run
  133. the shell command
  134.     bdftops <BDF_file_name> [<AFM_file1_name> ...] <your_gsf_file_name>
  135.       <font_name> <uniqueID> [<encoding_name>]
  136. e.g.,
  137.     bdftops pzdr.bdf ZapfDingbats.afm pzdr.gsf ZapfDingbats 4100000
  138. You may find it helpful to read, and to add an entry to, the fonts.mak
  139. file, which is a makefile for converting the standard Ghostscript fonts.
  140.  
  141. There is a similar utility to convert files from .PFB form to plain text
  142. .gsf form.  Run the shell command
  143.     pfbtogs <.PFB_file_name> <gsf_file_name>
  144. e.g.,
  145.     pfbtogs timesrmn.pfb ptmr.gsf
  146. Files in .PFA form can be used directly by Ghostscript -- no conversion is
  147. required, just an entry in Fontmap.
  148.  
  149. Starting in release 2.4, Ghostscript can also use .PFB fonts directly: you
  150. don't have to run pfbtogs, just put the .PFB file in the Fontmap.
  151.  
  152. Precompiling fonts
  153. ==================
  154.  
  155. You can compile any Type 1 font into C and link it into the Ghostscript
  156. executable.  (Type 1 fonts include any font whose name ends with .pfa or
  157. .pfb, and it also includes all the Ghostscript .gsf fonts except for the
  158. Hershey fonts.)  This doesn't have any effect on rendering speed, but it
  159. eliminates the time for loading the font dynamically, which may make a big
  160. difference in total rendering time, especially for multi-page documents.
  161. (Because of RAM and compiler limitations, you should only use compiled
  162. fonts on MS-DOS systems if you are using a 32-bit compiler such as Watcom
  163. C/386 or djgpp; you will run out of memory if you use compiled fonts with
  164. the Borland compiler.)  Fonts that have been precompiled and linked in
  165. this way do not need to appear in the Fontmap, although if they do appear
  166. there, no harm is done.
  167.  
  168. The utility for precompiling fonts is called font2c.  (Note that font2c is
  169. a PostScript language program, so you must have some version of
  170. Ghostscript already running to be able to run font2c.)  For example, to
  171. precompile the Times-Italic font,
  172.     font2c Times-Italic ptmri.c
  173. where the first argument is the font name and the second is the name of
  174. the .c file.  You can use any file name you want, as long as it ends in
  175. .c.  It doesn't have to be limited to 8 characters, unless your operating
  176. system requires this.  We suggest that you use names xxxx.c, where
  177. xxxx.gsf or xxxx.pfa is the name of the font file in the Fontmap file,
  178. just so you don't have to keep track of another set of names.  (If you are
  179. running on a VMS platform, or another platform where the C compiler has a
  180. limit on the length of identifiers, you must do something slightly more
  181. complicated; see the section 'Platforms with identifier length limits'
  182. below.)
  183.  
  184. Besides running font2c, you must arrange things so that the file will be
  185. compiled from C to machine code, and linked into the executable.  All
  186. environments except VMS use the same procedure for this, which we will now
  187. describe.  For VMS environments, the necessary information is contained in
  188. comments in the command files (vms-cc.mak and vms-gcc.mak); if you are
  189. using Ghostscript on VMS, ignore the rest of this subsection.
  190.  
  191. First, you must add the compiled fonts "feature" to your platform-specific
  192. makefile.  On MS-DOS systems, you edit turboc.mak, tbcplus.mak, or
  193. watc.mak; on Unix systems, you edit makefile.  Find the definition of
  194. FEATURE_DEVS in the makefile, e.g.,
  195.     FEATURE_DEVS=filter.dev dps.dev
  196. Add ccfonts.dev on the end, e.g.,
  197.     FEATURE_DEVS=filter.dev dps.dev ccfonts.dev
  198.  
  199. Next, you must add the specific fonts to the generic makefile.  On MS-DOS
  200. systems, you edit gs.mak; on Unix systems, you edit makefile.  Find the
  201. line in the relevant makefile that says
  202.     ccfonts_=ugly.$(OBJ)
  203. Edit this to add your compiled font file names, e.g.,
  204.     ccfonts_=ugly.$(OBJ) ptmri.$(OBJ)
  205. Then find the line that says
  206.     $(SHP)gsaddmod ccfonts -font Ugly
  207. Add your own fonts to the end of this line, e.g.,
  208.     $(SHP)gsaddmod ccfonts -font Ugly Times_Italic
  209. Notice that you must replace `-' by `_' in the font name.  If the line
  210. gets too long, add another line of the same form, e.g.,
  211.     $(SHP)gsaddmod ccfonts -font Ugly
  212.     $(SHP)gsaddmod ccfonts -font Times_Italic
  213. Now find the lines that say
  214.     ugly.$(OBJ): ugly.c $(CCFONT)
  215.         $(CC) $(CCFLAGS) -c ugly.c
  216. Add a similar pair of lines for each font, separating these entries from
  217. the existing entries and from each other by a blank line.  (The makefile
  218. includes lines for a few more fonts than this already.)  In our example,
  219.     ugly.$(OBJ): ugly.c $(CCFONT)
  220.         $(CC) $(CCFLAGS) -c ugly.c
  221.  
  222.     ptmri.$(OBJ): ptmri.c $(CCFONT)
  223.         $(CC) $(CCFLAGS) -c ptmri.c
  224.  
  225. Finally, run `make'.  The executable will now include the fonts you added.
  226. They will be present in FontDirectory when Ghostscript starts up.
  227.  
  228. Note that ugly.c, ncrr.c, etc. are not supplied with the Ghostscript
  229. fileset, since they are quite large and can easily be recreated using the
  230. font2c program as described above.
  231.  
  232. Platforms with identifier length limits
  233. ---------------------------------------
  234.  
  235. On some platforms, the C compiler and/or linker have a limit on the number
  236. of significant characters in an identifier.  On such platforms, you must
  237. do a little extra work.
  238.  
  239. Let N be the maximum number of significant characters in an identifier
  240. (typically 31).  For each font whose name is longer than N-5 characters,
  241. pick an arbitrary identifier that we will call the "short name".  This can
  242. be any string you want, as long as it contains only letters, digits, and
  243. underscores; is no longer than N-5 characters; and is not the same as any
  244. other font name or short name.  A good choice for this would be to use the
  245. name of the C file.  (There is no harm in doing this for fonts with names
  246. shorter than N-5 characters, it's just not necessary.)
  247.  
  248. You must do two different things for fonts that require a short name.
  249. First, you must supply the short name as a third argument to the font2c
  250. program.  For example, to compile NewCenturySchlbk-BoldItalic using the
  251. short name "pncbi",
  252.     font2c NewCenturySchlbk-BoldItalic pncbi.c pncbi
  253. Then when you add the font to the gsaddmod line in the makefile, use the
  254. short name, not the actual font name, e.g.,
  255.     $(SHP)gsaddmod ccfonts -font pncbi
  256. instead of
  257.     $(SHP)gsaddmod ccfonts -font NewCenturySchlbk_BoldItalic
  258. Everything else is as described above.
  259.  
  260. This procedure doesn't change the name of the font in the Fontmap, or as
  261. seen from within Ghostscript; it's just a workaround for a limitation of
  262. some older compilers.
  263.